﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Share/Index.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">


 <script type="text/javascript" language="JavaScript">
     var infomationPublish = { i_id: 0, i_title0: "", i_imageUrl: "", i_imageLink: "", i_template: 8, i_recommend: 0, i_state: 1, i_startTime: new Date(), i_endTime: new Date() };
     var mylist;
     var regular_input = {
         i_title0: { exp: /^.{1,100}$/, m: "请输入图片说明，100个字符以内" },
         i_recommend: { exp: /^[0-9]\d*$/, m: "只能输入整数" }
     }
     var mainForm = "";
     $(document).ready(function () {
         mylist = new TurnPage("mylist");
         mylist.pageSize = 8;
         mylist.callback = function () { ajax(); };

         function ajax() {
             var param = { pagesize: mylist.pageSize, pageno: mylist.currPage, template: 8 };
             $.post("/index/getlist.html?" + (new Date()).getTime(), param, function (data) {
                 data = $.evalJSON(data);
                 if (mylist.currPage == 1) {
                     mylist.total = $.grep(data, function (n, i) { return typeof (n.total) == "number"; })[0].total;
                     data = $.grep(data, function (n, i) { return typeof (n.total) == "undefined"; });
                 }
                 loadDta(data);
             });
         }

         var loadDta = function (list) {
             var sp = [];
             $("#mainTable tbody[name=mainlist]").html("");
             $.each(list, function (i, n) {
                 sp.push('<tr>');
                 sp.push('<td>' + n.i_title0 + '</td>');
                 sp.push('<td><a href="#" onclick="edit(' + n.i_id + ')" name="linkEdit" >修改</a> <a href="#" onclick="del(' + n.i_id + ')" name="linkDel" >删除</a></td>');
                 sp.push('</tr>');
             });
             $("#mainTable tbody[name=mainlist]").append(sp.join(''));
             //if (sp.length == 0) alert('没有符合条件的数据');
             $("#pager").html(mylist.getOutput());
         }
         $("input[name=buttSeek]").click(function () {
             mylist.currPage = 1;
             ajax();
         });
         $("input[name=buttReset]").click(function () {
             $("input[name=i_title0]").val('');
             $("input[name=i_imageLink]").val('');
             $('#i_imageUrl').attr('filepath', "");
             $(".uploadifyQueue [class=uploadifyQueueItem]").remove();
             $("input[name=i_recommend]").val('0');
             $("input[name=buttsend]").val('保存');
         });
         ajax();
         //
         $("input[name=buttsend]").click(function () {
             if (!$.checkFormValid("mainForm")) return false;
             $.fillObj(infomationPublish, "#mainForm");
             infomationPublish.i_imageUrl = $('#i_imageUrl').attr('filepath');
             if (infomationPublish.i_imageUrl == undefined || infomationPublish.i_imageUrl == "") {
                 alert("轮播广告必须上传图片"); return false;
             }
             $.post("/index/saveInfomationPublish.html", { infomationpublish: $.toJSON(infomationPublish) }, function (dta) {
                 alert("保存成功");
                 window.parent.frames["rightFrame"].location.reload();
                 ajax();
             });
         });
     });
     function edit(id) {
         $.post("/index/getinfomationbyid.html?" + (new Date()).getTime(), { res: id }, function (dta) {
             infomationPublish = $.evalJSON(dta);
             $.fillForm(infomationPublish, "#mainForm");
         });
         $("input[name=buttsend]").val('修改');
     }
     function del(id) {
         if (confirm("确定删除?")) {
             $.post("/index/deleteinfomation.html?" + (new Date()).getTime(), { res: id }, function (dta) {
                 alert("删除成功");
                 $("input[name='buttSeek']").click();
             });
         }
     }
</script>
<body>
    <table cellspacing="0" id="seekForm">
        <tr>
            <th>
                轮播广告管理
            </th>
        </tr>
        <tr>
        <td>
            <input type="button" name="buttSeek" value="查询" onclick="" class="btn1" />
        </td>
        </tr>
    </table>
    <table id="mainTable" cellspacing="0">
        <caption style="color: red; font-size: 15px; font-weight: bold">轮播广告列表</caption>
        <tr>
            <th>
                图片说明
            </th>
            <th>
            </th>
            </tr>
        <tbody name="mainlist">
        
        </tbody>
    </table>
    <div id="pager" class="pager">
    </div>
    <table cellspacing="0" id="mainForm">
        <tr>
            <th colspan="3">
                编辑
            </th>
        </tr>
         <tr>
            <td>图片说明*</td>
            <td><input id="i_title0" name="i_title0" maxlength="100" /></td>
            <td><span class="tsxx"></span></td>
        </tr>
        <tr>
            <td>链接</td>
            <td><input id="i_imageLink" name="i_imageLink" maxlength="200"  />点图片后所去的链接地址</td>
            <td><span class="tsxx"></span></td>
        </tr>
                 <tr>
            <td>轮播图片*</td>
            <td><% Html.RenderPartial("~/Views/Plugins/jqueryUploadFile.ascx", (ViewData["uploadFileId"] = "i_imageUrl"));%></td>
            <td><span class="tsxx"></span></td>
        </tr>   
        <tr>
            <td>排序规则</td>
            <td><input id="i_recommend" name="i_recommend" value="0"/>数字越大排在越前面</td>
            <td><span class="tsxx"></span></td>
        </tr>
        <tr>
            <td>生效时间</td>
            <td><input id="i_startTime" class="time" name="i_startTime" value="<%=System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" /></td>
            <td><span class="tsxx"></span></td>
        </tr>
        <tr>
            <td>失效时间</td>
            <td><input id="i_endTime" class="time"  name="i_endTime" value="<%=System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>" /></td>
            <td><span class="tsxx"></span></td>
        </tr>

        <tr class="main-status" id="mainstatus" style="display: none">
            <td colspan="3" class="bbd-bj-bom" align="center" height="41">
                正在验证表单....
            </td>
        </tr>
        <tr class="main-sub" id="mainsub">
            <td colspan="3" class="bbd-bj-bom" align="center" height="41">
                <input type="button" name="buttsend" class="btn1" style="width: 200px" 
                    value="新增" />
                <input type="button" name="buttReset" class="btn1" style="width: 200px" value="重置" />
            </td>
        </tr>
    </table>


</asp:Content>
